package com.anche.cywebnew.Controller.exchangeManager;

import com.anche.cywebnew.Pojo.exchangeManager.request.Page;
import com.anche.cywebnew.Pojo.exchangeManager.response.*;

import java.util.ArrayList;
import java.util.List;

public abstract class BaseController {

    public Object rendSuccess(String json){
        JsonResponse jsonResponse =new JsonResponse();
        jsonResponse.setId("1");
        jsonResponse.setJsonrpc("2.0");

        Result1 result = new Result1();
        result.setCode("1");
        result.setMsg("OK");


        List<DataJson> listdata =new ArrayList<>();
        DataJson dataJson = new DataJson();
        dataJson.setSourceId("DS-01");

        List<FieldValues> list = new ArrayList<>();
        FieldValues fieldValues1 = new FieldValues();
        fieldValues1.setField("code");
        fieldValues1.setValue("1");
        fieldValues1.setIsCode(0);
        fieldValues1.setCodeValue("");
        list.add(fieldValues1);
        FieldValues fieldValues2 = new FieldValues();
        fieldValues2.setField("message");
        fieldValues2.setValue("success");
        fieldValues2.setIsCode(0);
        fieldValues2.setCodeValue("");
        list.add(fieldValues2);

        FieldValues fieldValues3 = new FieldValues();
        fieldValues3.setField("data");
        fieldValues3.setValue(json);
        fieldValues3.setIsCode(0);
        fieldValues3.setCodeValue("");
        list.add(fieldValues3);


        dataJson.setFieldValues(list);
        listdata.add(dataJson);
        result.setData(listdata);

        Page page = new Page();
        page.setPageNo(1);
        page.setPageSize(10);
        page.setTotal(1);

        result.setPage(page);
        result.setSign("1qqqqwwwwwwwwwwwwww");

        jsonResponse.setResult(result);

        return jsonResponse;
    }


    public Object rendError(String msg){
        JsonResponse jsonResponse =new JsonResponse();
        jsonResponse.setId("1");
        jsonResponse.setJsonrpc("2.0");

        Result1 result = new Result1();
        result.setCode("0");
        result.setMsg("添加失败");

        List<DataJson> dataJsonList = new ArrayList<>();
        DataJson dataJson = new DataJson();
        dataJson.setSourceId("DS-01");

        List<FieldValues> list = new ArrayList<>();
        FieldValues fieldValues1 = new FieldValues();
        fieldValues1.setField("code");
        fieldValues1.setValue("0");
        fieldValues1.setIsCode(0);
        fieldValues1.setCodeValue("");

        list.add(fieldValues1);
        FieldValues fieldValues2 = new FieldValues();
        fieldValues2.setField("message");
        fieldValues2.setValue(msg);
        fieldValues2.setIsCode(0);
        fieldValues2.setCodeValue("");

        list.add(fieldValues2);

        FieldValues fieldValues3 = new FieldValues();
        fieldValues3.setField("data");
        fieldValues3.setValue(null);
        fieldValues3.setIsCode(0);
        fieldValues3.setCodeValue("");
        list.add(fieldValues3);


        dataJson.setFieldValues(list);

        dataJsonList.add(dataJson);
        result.setData(dataJsonList);

        Page page = new Page();
        page.setPageNo(1);
        page.setPageSize(10);
        page.setTotal(1);

        result.setPage(page);
        result.setSign("1qqqqwwwwwwwwwwwwww");

        jsonResponse.setResult(result);

        return jsonResponse;
    }


    public Object rendSuccess2(String json){
        JsonResponse2 jsonResponse =new JsonResponse2();
        jsonResponse.setId("1");
        jsonResponse.setJsonrpc("2.0");

        Result2Write result = new Result2Write();
        result.setCode("1");
        result.setMsg(json);


        List<DataRes> list = new ArrayList<>();
        DataRes dataRes1 = new DataRes();
        dataRes1.setOperationId("cd2a138e502e4ae5ba5dfb5a9af9df61");
        dataRes1.setOperationCode("1");
        dataRes1.setOperationMsg("");
        dataRes1.setOperationNum(null);
        list.add(dataRes1);


        result.setData(list);

        Page page = new Page();
        page.setPageNo(1);
        page.setPageSize(10);
        page.setTotal(1);


        result.setSign("1qqqqwwwwwwwwwwwwww");
        jsonResponse.setResult(result);

        return jsonResponse;
    }


    public Object rendError2(String json){
        JsonResponse2 jsonResponse =new JsonResponse2();
        jsonResponse.setId("1");
        jsonResponse.setJsonrpc("2.0");

        Result2Write result = new Result2Write();
        result.setCode("0");
        result.setMsg(json);


        List<DataRes> list = new ArrayList<>();
        DataRes dataRes1 = new DataRes();
        dataRes1.setOperationId("cd2a138e502e4ae5ba5dfb5a9af9df61");
        dataRes1.setOperationCode("1");
        dataRes1.setOperationMsg("");
        dataRes1.setOperationNum(null);
        list.add(dataRes1);


        result.setData(list);

        Page page = new Page();
        page.setPageNo(1);
        page.setPageSize(10);
        page.setTotal(1);


        result.setSign("1qqqqwwwwwwwwwwwwww");
        jsonResponse.setResult(result);

        return jsonResponse;
    }



}
